/*
 * Created by: 
 * Created: Tuesday, April 24, 2007
 */

using System.IO;

namespace TeleTwitter
{
    public interface IHelpFormDisplay
    {
        string HelpBody { set; }
    }
    public class HelpFormController
    {
        const string HTML_HELP_RESOURCE = "TeleTwitter.html.Help.html";
        const string HTML_CSS_RESOURCE = "TeleTwitter.html.Teletwitter.css";

        private readonly IHelpFormDisplay display;

        public HelpFormController(IHelpFormDisplay display)
        {
            this.display = display;
        }

        public void GetHelpString()
        {
            string templateHtml = GetResourceString(HTML_HELP_RESOURCE);

            // Parse ${css}
            string css = GetResourceString(HTML_CSS_RESOURCE);

            display.HelpBody = templateHtml.Replace("${css}", "<style type=\"text/css\" media=\"all\">" + css + "</style>");
        }

        private string GetResourceString(string templateHtml)
        {
            using (StreamReader reader = new StreamReader(GetType().Assembly.GetManifestResourceStream(templateHtml)))
                templateHtml = reader.ReadToEnd();
            return templateHtml;
        }

    }
}